package com.example;

import com.example.utils.JwtUtils;
import io.jsonwebtoken.Claims;


import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.Base64;

/**
 * @Author : lzy
 * @CreateTime : 2021/6/18
 * @Description :
 **/
@SpringBootTest
public class test {
    @Test
    public void test1() {

        // 生成token
        String s = JwtUtils.generateToken("111", 20L);
        System.out.println(s);
        // 验证
        Claims claims = JwtUtils.verifyJwt(s);
        System.out.println("claims:"+claims);
        String subject = claims.getSubject();
        String userId = claims.get("userId").toString();
        String openId =  claims.get("openId").toString();
        String sub = claims.get("sub").toString();
        System.out.println("subject:" + subject);
        System.out.println("userId:" + userId);
        System.out.println("openId:" + openId);
        System.out.println("sub:" + sub);
    }
}


